import axios, { AxiosInstance } from "axios";
import {
  type Config,
  CrawlerFileUtils,
  getRandomIP,
  getRandomUserAgent,
} from "../../utils/baseUtils.js";

const fileUtils = new CrawlerFileUtils<Config>(import.meta.url); 

// ===================创建一个 axios实例 ======================
const axiosInstance: AxiosInstance = axios.create({
  baseURL: "https://www.58pic.com",
  timeout: 10000,
});



axiosInstance.interceptors.request.use((config) => {
    config.headers["User-Agent"] = getRandomUserAgent();
    config.headers["X-Forwarded-For"] = getRandomIP();
    config.headers["X-Real-IP"] = getRandomIP();
    config.headers["Referer"] = "https://www.58pic.com";
    return config;
});

export { axiosInstance,fileUtils };
  




